package cn.cvs.mapper;

import cn.cvs.pojo.SysUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

/**
 * shiro 登录用
 */
public interface SysUserPlusMapper extends BaseMapper<SysUser> {
    @Select("SELECT u.*,r.role_name" +
            " FROM `sys_user` u" +
            " inner join sys_role r" +
            " on u.usr_role_id =r.role_id" +
            " where u.usr_name=#{usrName}")
    @Results(value = {
            @Result(property = "roleName", column = "role_name")
    })
    public SysUser getByUsrNameSysUser(String usrName);

    @Select("SELECT u.usr_id,u.usr_name,u.usr_password,u.usr_role_id,u.usr_flag,r.role_name" +
            " FROM `sys_user` u" +
            " inner join sys_role r" +
            " on u.usr_role_id =r.role_id" +
            " where u.usr_name=#{usrName}")
    @Results(value = {
            @Result(column = "usr_role_id"
                    , property = "role"
                    , one = @One(select = "cn.cvs.mapper.SysRoleMapper.selectById")
            )
    })
    public SysUser getByUsrNameSysUserAndRole(String usrName);
}
